<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" session="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<div style="text-align: center;">
	    <a href="logout.do" >登出/退出</a>
	    <form action="userfindbypage.do" method="post">
	    	用户名:<input type="text" name="keyword1" value="${requestScope.page.keywords[0]}"/>
	    	地址:<input type="text" name="keyword2" value="${requestScope.page.keywords[1]}"/>
	    	<input type="submit" value="模糊查询" />
	    </form>
	  <c:if test="${!empty requestScope.page.data}">
		<div style="font-size: 30px;font-weight: bold;">显示用户信息</div>
		<table border="=1" align="center">
			<tr>
				<th>序号1</th>
				<th>序号2</th>
				<th>id</th>
				<th>用户名</th>
				<th>密码</th>
				<th>年龄</th>
				<th>地址</th>
				<th>头像</th>
				<th>删除</th>
				<th>修改</th>
			</tr>
		  <c:forEach var="user" items="${requestScope.page.data}" varStatus="vs">
			<tr>
				<td>${vs.index+1}</td>
				<td>${vs.count}</td>
				<td>${user.id}</td>
				<td>${user.name}</td><!-- user.getName() -->
				<td>${user.password}</td>
				<td>${user.age}</td>
				<td>${user.address}</td>
				<td><img src="images/${user.head}" width="50" height="50"></td>
				<td>
				   <c:if test="${sessionScope.user_name!=user.name}">
				      	<a href="userdelete.do?id=${user.id}">删除</a>
				   </c:if>				   
				</td>
				<td><a href="userfindbyid.do?id=${user.id}">修改</a></td>
			</tr>
		  </c:forEach>
		</table>
		<!-- 分页条开始 -->
		<!-- 最多一个页,则不显示分页调 -->
		<c:if test="${requestScope.page.totalPage>1}">
			【${requestScope.page.currentPage}/${requestScope.page.totalPage}】
			<!-- 第一页情况  下一页 尾页 -->
			<c:if test="${requestScope.page.currentPage==1}">
				<a href="userfindbypage.do?currentPage=2&keyword1=${requestScope.page.keywords[0]}&keyword2=${requestScope.page.keywords[1]}">下一页</a>
			    <a href="userfindbypage.do?currentPage=${requestScope.page.totalPage}&keyword1=${requestScope.page.keywords[0]}&keyword2=${requestScope.page.keywords[1]}">尾页</a>
			</c:if>			
			<!-- 不是第一页,也不是最后一页  首页  上一页  下一页  尾页    -->
			<c:if test="${requestScope.page.currentPage>1 && requestScope.page.currentPage<requestScope.page.totalPage}">
				<a href="userfindbypage.do?currentPage=1&keyword1=${requestScope.page.keywords[0]}&keyword2=${requestScope.page.keywords[1]}">首页</a>
				<a href="userfindbypage.do?currentPage=${requestScope.page.previousPage}&keyword1=${requestScope.page.keywords[0]}&keyword2=${requestScope.page.keywords[1]}">上一页</a>
				<a href="userfindbypage.do?currentPage=${requestScope.page.nextPage}&keyword1=${requestScope.page.keywords[0]}&keyword2=${requestScope.page.keywords[1]}">下一页</a>
				<a href="userfindbypage.do?currentPage=${requestScope.page.totalPage}&keyword1=${requestScope.page.keywords[0]}&keyword2=${requestScope.page.keywords[1]}">尾页</a>
			</c:if>			
			<!-- 最后一页   首页  上一页 -->
			<c:if test="${requestScope.page.currentPage==requestScope.page.totalPage}">
				<a href="userfindbypage.do?currentPage=1&keyword1=${requestScope.page.keywords[0]}&keyword2=${requestScope.page.keywords[1]}">首页</a>
				<a href="userfindbypage.do?currentPage=${requestScope.page.previousPage}&keyword1=${requestScope.page.keywords[0]}&keyword2=${requestScope.page.keywords[1]}">上一页</a>
			</c:if>			
		</c:if>		
		<!-- 分页条结束 -->	
      </c:if>
      <c:if test="${empty requestScope.page.data}">
      	<span style="color:red;font-style:italic;">
      		没有符合条件的数据,请更换其他的条件再次查询
      	</span>
      </c:if>
	</div>
</body>
</html>